// 获取路由参数

export const getRouteParams = (props = {}) => {
    const {match = {}} = props;
    const {params = {}} = match;
    return params;
};

// 获取地址参数
export const getUrlParams = (url = "") => {
    let params = {};

    const urlParams = url.slice(url.indexOf("?") + 1).split("&");
    urlParams.forEach((item) => {
        const param = item.split("=");
        params[param[0]] = param[1];
    });

    return params;
};

export const openLink = (type, id) => {
    switch (type) {
        case "doc":
            try {
                window.em.openLink({
                    url: `spa/document/static4mobile/index.html#/doc/${id}`, // 要打开链接的地址
                    openType: 2, // 打开方式 1:当前窗口 2:新窗口 3:系统默认浏览器
                    sysId: window.localStorage.emobile_ec_id    // 集成系统ID
                });
            } catch (e) {
            }
            break;
        default:
            break;
    }

}
